﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyDotNetCodes.日志
{
    /// <summary>
    /// 写Windows系统日志
    /// </summary>
    public class WindowsEventLogTool
    {
        /*
       *  测试用例
       *  OutSystemLog("图景快手","信息一", EventLogEntryType.Information);
       *  OutSystemLog("图景快手", "警告一", EventLogEntryType.Warning);
       *  OutSystemLog("图景快手", "错误一", EventLogEntryType.Error); 
       */

        /// <summary>
        /// 输出到系统日志
        /// </summary>
        /// <param name="source">事件来源</param>
        /// <param name="message">信息</param>
        /// <param name="logEntryType">级别</param>
        public static void OutSystemLog(string source, string message, EventLogEntryType logEntryType)
        {
            EventLog log = new EventLog();
            log.Source = source;
            log.WriteEntry(message, logEntryType);

        }
    }
}
